package com.example.combwyaq.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;

import androidx.annotation.Nullable;

public class DotWidget extends LinearLayout {

    private Paint redPaint ;//画笔
    private Boolean isShow = false;//是否显示 默认隐藏

    public DotWidget(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }
    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        redPaint = new Paint();
        redPaint.setColor(Color.RED);
        redPaint.setAntiAlias(true);//抗锯齿
        redPaint.setDither(true);//防抖动
        redPaint.setStyle(Paint.Style.FILL_AND_STROKE);//全部填充
    }
    public void setIsShow(Boolean isShow){
        this.isShow = isShow;
        invalidate();
    }

    public Boolean getIsShow(){
        return isShow;
    }
    //重写onDraw
    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        if (isShow){
            canvas.drawCircle(getWidth()-6,6,6,redPaint);
        }
    }
    public void setRedPaint(Paint paint){
        this.redPaint = paint;
        this.isShow = true;
        invalidate();
    }
}
